﻿using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.Linq;
using System.Text;
using System.Windows.Forms;
using System.IO;

namespace SvD_Templates
{
    public partial class loginForm : Form
    {
        private string rutaLocalApp = @"C:\Program Files\SvD Templates\App";

        public loginForm()
        {
            InitializeComponent();
        }

        private void cancel_Click(object sender, EventArgs e)
        {
            this.Close();
        }

        private void register_Click(object sender, EventArgs e)
        {
            setLogin();
        }

        private void setLogin()
        {
            try
            {
                if (cajaID.Text != "" && cajaPass.Text != "")
                {
                    FileStream file = new FileStream(rutaLocalApp + "/AD", FileMode.OpenOrCreate, FileAccess.Write);
                    TextWriter tw = new StreamWriter(file);
                    tw.Write(cajaID.Text + "|" + cajaPass.Text);
                    tw.Close();
                }
                this.Close();
            }
            catch (Exception ex)
            {
                MessageBox.Show(ex.Message + Environment.NewLine + ex.StackTrace);
            }
        }

        private void loginForm_Load(object sender, EventArgs e)
        {

        }

        private void cajaPass_KeyDown(object sender, KeyEventArgs e)
        {
            if (e.KeyValue == 13)
            {
                setLogin();
            }

        }
    }
}
